package com.ve.everything.searcher;

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.UUID;

public class IndexMain {
    public static void main(String[] args) throws Exception {
        Files.createDirectories(Paths.get(Constants.PATH));
        Date currentDateObject = new Date();
        Files.walkFileTree(Paths.get("C:\\code\\Everything4J\\src"), new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

                if (!file.getFileName().toString().endsWith(".dll")) {
                    String id = UUID.randomUUID().toString();
                    try {
                        LuceneIndex.indexDocument(
                                file.toFile(),
                                /*id,
                                "ve",
                                new SimpleDateFormat("hh:mm").format(currentDateObject),
                                new SimpleDateFormat("yyMMdd").format(currentDateObject),*/
                                 new String[]{"1"}
                        );
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

                return super.visitFile(file, attrs);
            }
        });


    }
}
